package com.vay.de.dang.online.ui.my;

import android.os.Bundle;

import com.vay.de.dang.online.ui.WithBack1Activity;
import com.vay.de.dang.online.util.VnUtil;
import com.vay.de.dang.online.view.DialogWarring;
import com.vay.de.dang.online.ui.HomeActivity;
import com.vay.de.dang.online.util.VnContext;

import com.vay.de.dang.online.R;
import com.vay.de.dang.online.databinding.ActivitySettingBinding;

public class SetActivity extends WithBack1Activity {

    private ActivitySettingBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySettingBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        findViewById(R.id.bnt_back_home).setOnClickListener(view -> finish());
        binding.versionTv.setText("v" + VnContext.versionName);

        binding.bntLogout.setOnClickListener(view -> {
            new DialogWarring(mActivity)
                    .setTitleText(R.string.label_warring)
                    .setHintText(R.string.label_warring_logout)
                    .showConfirm(() -> {
                        VnContext.instance().logout();
                        HomeActivity.reOpen(mActivity);
                        finish();
                    });
        });

        binding.clearLayout.setOnClickListener(view -> {
            VnUtil.deleteCache();
            showHint(R.string.label_clear_cache_ok);
        });
    }

}
